package com.info33.platform.common.mvc.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonView;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.info33.platform.common.mvc.jsonview.property.*;
import com.info33.platform.common.validated.UpdateValidated;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * 所有对象的基类，所有对象必须继承
 *
 * @author Administrator
 */
@Data
public class BaseEntity implements java.io.Serializable {

    private static final long serialVersionUID = 1L;

    @JsonView(JsonViewId.class)
    @JsonSerialize(using = ToStringSerializer.class)
    @NotNull(groups = {UpdateValidated.class}, message = "id 不能为空")
    @TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "id")
    private Long id;

    @JsonView(JsonViewRemarks.class)
    @ApiModelProperty(value = "备注", hidden = true)
    private String remarks;

    @JsonView(JsonViewSort.class)
    @ApiModelProperty(value = "排序", hidden = true)
    private Integer sort;

    @JsonView(JsonViewVersion.class)
    @ApiModelProperty(value = "数据版本", hidden = true)
    @Version
    private Integer version;

    @JsonView(JsonViewStatus.class)
    @ApiModelProperty(value = "数据状态", hidden = true)
    private Integer status;

    @JsonView(JsonViewCreateBy.class)
    @ApiModelProperty(value = "创建人 id", hidden = true)
    @TableField(value = "create_by", fill = FieldFill.INSERT)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long createBy;

    @JsonView(JsonViewCreateDate.class)
    @ApiModelProperty(value = "创建时间", hidden = true)
    @TableField(value = "create_date", fill = FieldFill.INSERT)
    private Date createDate;

    @JsonView(JsonViewUpdateBy.class)
    @ApiModelProperty(value = "修改人 id", hidden = true)
    @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long updateBy;

    @JsonView(JsonViewUpdateDate.class)
    @ApiModelProperty(value = "修改时间", hidden = true)
    @TableField(value = "update_date", fill = FieldFill.INSERT_UPDATE)
    private Date updateDate;

    @JsonView(JsonViewUuid.class)
    @ApiModelProperty(value = "uuid", hidden = true)
    @TableField(value = "uuid", fill = FieldFill.INSERT)
    private String uuid;

    @JsonView(JsonViewTenantId.class)
    @ApiModelProperty(value = "租户 id", hidden = true)
    @TableField(value = "tenant_id", fill = FieldFill.INSERT)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long tenantId;
}
